<?php
	/**
	* 
	*/
	class carconfModel{

		public $_table = 'carconf';//设置表名
		
		//取一组车辆配置信息
		function get_carinfo_one(){
			$sql = 'select * from '.$this -> _table.' where id = 1';  
			$data = DB::findOne($sql);
			$arr = array();
			foreach ($data as $key => $value) {
				$arr[$key] = explode(',',$value);
			}
			return $arr;
		}
		
		public function setcarconf(){
			$confName = addslashes($_GET['confName']);
			$oldvalue = addslashes($_GET['oldvalue']);
			$value = addslashes($_GET['value']);
			if($_GET['oldvalue']){
				$sql = 'update '.$this -> _table." set ".$confName." = replace(".$confName.",'".$oldvalue."','".$value."') where id = 1";
			}else{
				$sql = "update ".$this -> _table." set ".$confName." = CONCAT(".$confName.",'".$value."') where id = 1";
			}
			return DB::query($sql);
		}

		//删除指定字段数据中的xx值
		public function delcarconf(){
			$confName = addslashes($_GET['confName']);
			$value = addslashes($_GET['value']);
			$sql = 'update '.$this -> _table." set ".$confName." = replace(".$confName.",'".$value."','') where id = 1";
			return DB::query($sql);
		}

	}
?>